package com.le.tester.controller;

import com.github.pagehelper.PageInfo;
import com.le.tester.common.ServerResponse;
import com.le.tester.dto.CommonDto;
import com.le.tester.entity.OgPost;
import com.le.tester.sevice.OGPostService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * createTime：2022/1/12 16:56
 * description：多线程千万数据使用
 */
@Controller
@RequestMapping("/og/")
public class OGController {

    private static final Logger LOG = LoggerFactory.getLogger(OGController.class);


    @Resource
    private OGPostService ogPostService;

    @ResponseBody
    @RequestMapping("getOGPostInfo")
    public ServerResponse<PageInfo<List<OgPost>>> getPostInfo(CommonDto commonDto) {
        //获取ogPost中的数据异常
        try {
            PageInfo<List<OgPost>> ogPostInfoPage = ogPostService.getPostInfo(commonDto);
            return ServerResponse.createBySuccess(ogPostInfoPage);
        } catch (Exception e) {
            LOG.info("获取ogPost中的信息异常：{}", e.getMessage());
            return ServerResponse.createByError();
        }
    }
}
